package com.dlc.shop.api.controller;

import com.dlc.shop.bean.app.dto.SimpleDeliveryDto;
import com.dlc.shop.bean.model.Delivery;
import com.dlc.shop.common.response.ServerResponseEntity;
import com.dlc.shop.common.util.BeanUtil;
import com.dlc.shop.service.DeliveryService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author LGH
 */
@Slf4j
@RestController
@RequestMapping("/p/delivery")
@Tag(name = "查看物流接口")
@AllArgsConstructor
public class DeliveryController {

    private final DeliveryService deliveryService;


    @GetMapping("/list")
    @Operation(summary = "查看物流列表" , description = "查看物流列表")
    public ServerResponseEntity<List<SimpleDeliveryDto>> checkDelivery() {
        List<Delivery> list = deliveryService.list();
        List<SimpleDeliveryDto> deliveryDtos = BeanUtil.mapAsList(list, SimpleDeliveryDto.class);
        return ServerResponseEntity.success(deliveryDtos);
    }
}
